package com.yt.service.impl;

import com.yt.service.SendProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @Classname SendProviderImpl
 * @Description
 * @Date 2021/10/25 10:41
 * @Create by 杨涛
 */
//spring stream 的流向，源是向中心发送，目标，是由中心发送。
@EnableBinding(Source.class)//流有方向，有源有目标，这里是的流的源
public class SendProviderImpl implements SendProvider {
    @Resource
    @Output(Source.OUTPUT) //通道有类型，注入要选择
    public MessageChannel out;
    @Override
    public void send() {
        out.send(MessageBuilder.withPayload(
                "message - provider 6000"+ UUID.randomUUID()).build());
    }
}
